<% @page_title = "Firewalls" %>
<%== render("networking/tabbar") %>

<div class="grid gap-6">
  <%== part(
    "components/table_card",
    headers: ["Name", "Location", "Description"],
    rows: @firewalls.map do |fw|
      [
        [
          [fw[:name], {link: @project_data[:path] + fw[:path]}],
          fw[:location],
          fw[:description]
        ],
        {id: "fw-#{fw[:id]}"}
      ]
    end,
    empty_state: {
      icon: "hero-firewall",
      title: "No firewalls",
      description: "You don't have permission to create firewalls."
    }.merge(has_project_permission("Firewall:create") ? {
      description: "Get started by creating a new firewall.",
      button_link: "#{@project_data[:path]}/firewall/create",
      button_title: "Create Firewall"
    } : {})
  ) %>

  <% if @firewalls.count > 0 && has_project_permission("Firewall:create") %>
    <div class="flex justify-end">
      <%== part("components/button", text: "Create Firewall", link: "firewall/create") %>
    </div>
  <% end %>
</div>
